From 18ac70847a792de2cffe4f7077fd669fa5af3aa8 Mon Sep 17 00:00:00 2001 From: robertl Date: Tue, 16 Nov 2004 03:50:19 +0000 Subject: [PATCH] Suppress zero byte writes for benefit of Bob Anderson's Keyspan USB/Serial adapter. --- gpsbabel/jeeps/gpsserial.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gpsbabel/jeeps/gpsserial.c b/gpsbabel/jeeps/gpsserial.c index b2a51bb22..f7d5d631a 100644 --- a/gpsbabel/jeeps/gpsserial.c +++ b/gpsbabel/jeeps/gpsserial.c @@ -180,6 +180,17 @@ int32 GPS_Serial_Flush(int32 fd) int32 GPS_Serial_Write(int32 ignored, const void *obuf, int size) { DWORD len; + + /* + * Unbelievably, the Keyspan PDA serial driver 3.2, a "Windows + * Certified driver", will crash the OS on a write of zero bytes. + * We get such writes from upstream when there are zero payload + * bytes. SO we trap those here to stop Keyspan & Windows from + * nuking the system. + */ + if (size == 0) { + return 0; + } WriteFile (comport, obuf, size, &len, NULL); if (len != size) { fatal ("Write error. Wrote %d of %d bytes.", len, size); -- 2.30.2